package com.datang.pet.api.suggestController;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-07-18 22:45
 * @notify
 * @version 1.0
 */

import com.datang.pet.common.response.Result;
import com.datang.pet.common.utils.MD5;
import com.datang.pet.pojo.Suggest;
import com.datang.pet.service.SuggestService;
import com.datang.pet.vo.AddSuggestRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SuggestController {

    @Autowired
    private SuggestService suggestService;

    @PostMapping("/addSuggest")
    public Result addSuggest(@RequestBody AddSuggestRequest suggestRequest)throws Exception{
        try {
            suggestRequest.setUserId(MD5.decryptData(suggestRequest.getUserId()));
        }catch (Exception e){
            throw new Exception("用户id解密失败");
        }

        suggestService.addSuggest(suggestRequest);
        return Result.ok("ok");
    }
}
